package com.warmlight.voicepacket.ui.user.dialog;

import android.app.Dialog;
import android.os.Bundle;
import android.support.v7.app.AppCompatDialogFragment;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;

import com.warmlight.voicepacket.R;

public class MySoundDialog extends AppCompatDialogFragment {

    public interface OnTypeClick{
        void type(String type);
    }

    private OnTypeClick onTypeClick;

    public void setOnTypeClick(OnTypeClick onTypeClick){
        this.onTypeClick = onTypeClick;
    }

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {

        Dialog dialog = new Dialog(getContext(), R.style.share_dialog);
        dialog.setContentView(R.layout.dialog_user_sound);
        dialog.setCanceledOnTouchOutside(true);
        dialog.setCancelable(true);
        setCancelable(true);


        Window window = dialog.getWindow();
        window.setWindowAnimations(R.style.dialogAnim3);
        window.setGravity(Gravity.BOTTOM);
        WindowManager.LayoutParams attributes = window.getAttributes();
        attributes.width = WindowManager.LayoutParams.MATCH_PARENT;
        window.setAttributes(attributes);

        initview(dialog);


        return dialog;

    }

    private void initview(Dialog dialog) {
        TextView tv_share = dialog.findViewById(R.id.tv_share);
        TextView tv_del = dialog.findViewById(R.id.tv_del);
        TextView tv_love = dialog.findViewById(R.id.tv_love);
        TextView tv_public = dialog.findViewById(R.id.tv_public);
        tv_share.setVisibility(View.GONE);
        tv_love.setVisibility(View.GONE);
        tv_public.setVisibility(View.GONE);

        tv_del.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
                if (onTypeClick != null){
                    onTypeClick.type("del");
                }
            }
        });
    }

}